package com.wxq.yaoxia;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.wxq.yaoxia.mainborad.YXMainboradActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;

public class YXAboutActivity extends YXBaseActivity {

	ListView aboutLV ;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentViewWithTopbar(R.layout.yx_about, R.layout.yx_topbar);
		aboutLV = (ListView) findViewById(R.id.aboutLV);
		setAboutListView();
		aboutLV.setOnItemClickListener(
				new OnItemClickListener()
				{

					@Override
					public void onItemClick(AdapterView<?> parent, View view,
							int position, long id) {
						// TODO Auto-generated method stub
						Intent intent = new Intent();
						
						switch (position) {
						case 0:
							intent.putExtra("text", R.string.about_about_hint);
							intent.putExtra("image", 0);
							break;
						
						case 1:
							intent.putExtra("text", R.string.about_use_hint);
							intent.putExtra("image", 0);
							break;
							
						case 2:
							intent.putExtra("text", R.string.about_private_hip);
							intent.putExtra("image", 0);
							break;
							
						case 3:
							intent.putExtra("text", R.string.about_qualification_hip);
							intent.putExtra("image", R.drawable.yx_about_qua);
							break;
						default:
							break;
						}
						
						intent.setClass(YXAboutActivity.this, YXAboutDetailActivity.class);
						YXAboutActivity.this.startActivity(intent);
					}
				});
	}

	@Override
	public void setTopBarButtonListener() {
		// TODO Auto-generated method stub
		Button leftBtn = (Button) findViewById(R.id.btnLeft);
    	Button rightBtnButton = (Button) findViewById(R.id.btnRight);
    	TextView centerTV = (TextView) findViewById(R.id.centerTV);
    	
    	leftBtn.setVisibility(View.VISIBLE);
    	leftBtn.setText("返回");
    	leftBtn.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
			}
		});
    	rightBtnButton.setVisibility(View.VISIBLE);
//    	rightBtnButton.setText("药");
    	rightBtnButton.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent = new Intent();
				intent.setClass(YXAboutActivity.this, YXMainboradActivity.class);
				YXAboutActivity.this.startActivity(intent);
			}
		});
    	centerTV.setVisibility(View.VISIBLE);
    	centerTV.setText("关于");
	}
	
	public List< Map<String, String> > getAboutData() {
		List< Map<String, String> > list = new ArrayList<Map<String,String>>();
		    Map<String, String> temp1 = new HashMap<String, String>();
		    temp1.put("name", "关于药侠");
		    Map<String, String> temp2 = new HashMap<String, String>();
		    temp2.put("name", "使用条款");
		    Map<String, String> temp3 = new HashMap<String, String>();
		    temp3.put("name", "隐私保护");
		    Map<String, String> temp4 = new HashMap<String, String>();
		    temp4.put("name", "药品信息服务资格");
		    
			list.add(temp1);
			list.add(temp2);
			list.add(temp3);
			list.add(temp4);
		
		return list;
	}
	
	public void setAboutListView() {
		List<Map<String, String>> list = getAboutData();
		
		SimpleAdapter simpleAdapter = new SimpleAdapter(this, list, R.layout.shool_item, new String []{"name"}, new int []{android.R.id.text1});
		aboutLV.setAdapter(simpleAdapter);
	}

}
